/*
 *   Copyright (C) 2008 - 2009  FireBalls
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// includes
#include "Log.h"

Log::~Log()
{
    // if the file is still open close it
    if(file.is_open())
        file.close();
}

bool Log::OpenFile(const char* fileName)
{
    // try to open the file
    file.open(fileName, std::ofstream::out);

    if(!file.is_open())
        return false;

    return true;
}

void Log::Write(const char* var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(const unsigned char* var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(char var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(unsigned char var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(short var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(unsigned short var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(int var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(unsigned int var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(long var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(unsigned long var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(long long var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(unsigned long long var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(float var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(double var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Write(long double var)
{
    if(!file.is_open())
        return;

    file << var;

}

void Log::Endl()
{
    if(!file.is_open())
        return;

    file << std::endl;
}
